{extend name="public/nav"}

{block name="css"}
<link href="__ADMIN__/umeditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
{/block}

{block name="main"}
<div class="admin-content">
  <div class="am-cf am-padding">
    <div class="am-fl am-cf"> <strong class="am-text-primary am-text-lg">新建文档</strong>
      /
      <small>Create a new document</small>
    </div>
  </div>

  <hr/>

  <div class="am-g">

    <div class="am-u-sm-8 am-u-md-4 am-u-md-push-8"></div>

    <div class="am-u-sm-12 am-u-md-12 am-u-md-pull-1">
      <form class="am-form am-form-horizontal" method="post" action="{:U('album/create')}" id="conf_update" enctype="multipart/form-data">

      <div class="am-form-group">
        <label for="user-email" class="am-u-sm-2 am-form-label">标题</label>
        <div class="am-u-sm-10">
          <input type="text" id="user-email" placeholder="请输入文档标题，长度为1-40个字符" name="title" value=""></div>
      </div>
      <div class="am-form-group">
            <label for="user-email" class="am-u-sm-2 am-form-label">分类</label>
            <div class="am-u-sm-5">
            <select id="sort1" onchange="getSort(this.value)">
              {foreach $sort as $v}
              <option value="{$v.id}">{$v.sname}</option>
              {/foreach}
            </select>
          </div>
          <div class="am-u-sm-5" id="junior">
        </div>
      </div>
      <div class="am-form-group">
        <label for="user-email" class="am-u-sm-2 am-form-label">作者</label>
        <div class="am-u-sm-10">
          <input type="text" id="user-email" placeholder="请输入文档作者" name="author" value=""></div>
      </div>

      <div class="am-form-group">
        <label for="user-intro" class="am-u-sm-2 am-form-label">内容</label>
        <div class="am-u-sm-10">
          <textarea class="" id="content" placeholder="输入个人简介"></textarea>
        </div>
      </div>



      <!-- <div class="am-form-group">
        <label for="user-email" class="am-u-sm-4 am-form-label">状态 / Status</label>
        <div class="am-btn-group am-u-sm-8" data-am-button>
          <label class="am-btn am-btn-default am-btn-xs am-active">
            <input type="radio" name="status" id="option1" value="1" checked> 公开
          </label>
          <label class="am-btn am-btn-default am-btn-xs">
            <input type="radio" name="status" id="option2" value="3" > 不公开
          </label>
        </div>
      </div> -->

      <div class="am-form-group">
        <div class="am-u-sm-8 am-u-sm-push-2">
          <input type="hidden" name="update_time" value="{:time()}">
          <span><a href="#" onclick="actionPost()" class="am-btn am-btn-primary">保存修改</a></span>
      </div>
    </form>
  </div>
</div>
</div>
{/block}

{block name="js"}
<script type="text/javascript" charset="utf-8" src="__ADMIN__/umeditor/umeditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__ADMIN__/umeditor/umeditor.min.js"></script>
<script type="text/javascript" src="__ADMIN__/umeditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
    //实例化编辑器
    var um = UM.getEditor('content');
    function actionPost(){
        var content = um.getContent();
        alert(content);
    }

    $(function(){
        var sid = $("#sort1").val();
        getSort(sid);
    })


    //ajax 获取分类
    function getSort(sid){
        purge(sid);
        $.post('{:U("api/sorting/getsort")}',{sid:sid},function(data){
            $("#junior").empty();
            var H = '<select name="pid" >';
            H += '<option value="'+sid+'">上级分类</option>';
            if(!data.error){
                $.each(data,function(n,value){
                    H += '<option value="'+value.id+'">'+value.sname+'</option>';
                });
            }
            H += '</select>';
            $("#junior").html(H);
        },'json');
    }

    function purge(sid){
        $("#junior").empty();
        var H = '<select name="pid" >';
        H += '<option value="'+sid+'">上级分类</option>';
        H += '</select>';
        $("#junior").html(H);
    }


</script>
{/block}
